package com.api;

import com.api.core.response.Result;
import com.api.user.model.Identification;
import com.api.user.model.RegisterInput;
import com.api.user.service.IdentificationService;
import com.api.user.service.UserInfoService;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.mock.web.MockHttpSession;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;

import javax.annotation.Resource;
import javax.persistence.Transient;
import java.util.Date;
import java.util.Map;

//@RunWith(SpringRunner.class)
//@SpringBootTest(classes = GameApplication.class)
public class UserTestCase {
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private IdentificationService identificationService;

    @Autowired
    private WebApplicationContext context;
    @Autowired
    private WebApplicationContext wac;

    private MockMvc mvc;

    @Before
    public void setupMockMvc() {
    }

//    @Test
//    @Transient
    public void list() throws Exception {
        for (int i = 90; i <150 ; i++) {
            RegisterInput registerInput = new RegisterInput();
            registerInput.setAvatar("image/img/pic_3_1619415699152.jpg");
            registerInput.setEmail("test"+i+"@gmail.com");
            registerInput.setFullName("test"+i);
            registerInput.setLoginName("test"+i+"@gmail.com");
            registerInput.setPassword("test"+i);
            registerInput.setRegisterType("google");
            registerInput.setUserType(2);
            registerInput.setVerificationCode("9876");
            Result result =  userInfoService.register(registerInput);
            Identification identification = new Identification();
            identification.setCreateTime(new Date().getTime());
            Map<String,Object> res = (Map<String, Object>) result.getData();
            Map<String,Object> data = (Map<String, Object>) res.get("info");
            identification.setUserId((Long) data.get("userId"));
            identification.setType("nric");
            identification.setBackUrl("image/img/pic_3_1619415699152.jpg");
            identification.setFrontUrl("image/img/pic_3_1619415699152.jpg");
            identificationService.add(identification);
        }
    }

    @Test
    public void add() throws Exception {
    }

    @Test
    public void update() throws Exception {
    }

    @Test
    public void delete() throws Exception {
    }

}